# -*- coding: utf-8 -*-
# @Time : 2023/9/27 14:28
# @Author : ZH
# @File : 5.py
# @Software: PyCharm
class Solution:
    def longestPalindrome(self, s: str) -> str:
        if len(s) == 1:
            return s
        if len(s) == 2:
            if s[0] == s[1]:
                return s
        count = 0
        start = 0
        end = 0
        for i in range(len(s)):
            for j in range(len(s), i, -1):
                if s[i:j] == s[j:i:-1]:
                    if count < j-i:
                        count = j-i
                        start = i
                        end = j
        return s[start:end+1]


        pass

if __name__ == '__main__':
    so = Solution()
    z = so.longestPalindrome(s='cbbd')
    print(z)



